package br.com.agenda.negocio.entity;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import br.com.agenda.exception.DataIncorretaException;
import br.com.agenda.exception.HoraIncorretaException;

public class EventoDataHora extends UnicastRemoteObject implements IEventoDataHora, Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3338372345702880011L;
	private Calendar data;
	
	public EventoDataHora(String dataString, String hora) throws DataIncorretaException, HoraIncorretaException, RemoteException{
		String[] dataToken = dataString.split("/");
		if(dataToken.length < 3){
			throw new DataIncorretaException("Formato da data Incorreto");
		}
		String[] horaToken = hora.split(":");
		if(horaToken.length < 2){
			throw new HoraIncorretaException("Formato da hora Incorreta");
		}
		
		this.data= new GregorianCalendar(Integer.parseInt(dataToken[0]), Integer.parseInt(dataToken[1]) - 1, Integer.parseInt(dataToken[2]),
				Integer.parseInt(horaToken[0]), Integer.parseInt(horaToken[1]));
		
	}
	
	public Calendar getData() throws RemoteException {
		return data;
	}
	
	
}
